<?php
declare (strict_types=1);

namespace app\api\controller;

use app\common\tool\Result;
use think\facade\View;
use think\response\Json;
use app\common\model\Answer as AnswerModel;

class Answer extends Base
{
    /**
     * get: 答疑列表
     * path: list
     * method: list
     */
    public function getList()
    {
        $list = AnswerModel::where(['uid'=>$this->user->id,'is_del'=>0])->field('id,comment,rcomment,create_time,reply_time')->order('create_time','asc')->select();
        return Result::success('获取成功',$list);
    }


    /**
     * post: 加入购物车
     * path: addAnswer
     * method: addAnswer
     * param: comment - {string} 问题描述
     */
    public function addAnswer()
    {
        $param = $this->request->post();
        $add = AnswerModel::add($param,$this->user);
        if($add['code']>0)
        {
            return Result::success($add['msg']);
        }else{
            return Result::fail($add['msg']);
        }

    }
}


